package com.tbit.uqbike.client.controller;

import com.tbit.uqbike.client.constant.ResponseCode;
import com.tbit.uqbike.client.exception.BaseException;
import com.tbit.uqbike.client.pojo.BusDesConfig;
import com.tbit.uqbike.client.service.BusDesConfigService;
import com.tbit.uqbike.client.util.Assert;
import com.tbit.uqbike.client.util.OutputUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * 业务提示自定义描述
 *
 * @Author: chen
 * @Description: 业务提示自定义描述
 * @Date: 创建于 15:20 2020/12/30
 */
@Controller
@RequestMapping("/busDes")
public class BusDesConfigController {
    @Autowired
    private BusDesConfigService busDesConfigService;


    /**
     * 通过品牌id和类型获取
     *
     * @param accountId 帐户id
     * @param busType   总线类型
     * @param response  响应
     * @ignoreParams request
     */
    @RequestMapping("/getByAccountId")
    public void getByImageId(Integer accountId, Integer busType, HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> map = new HashMap<String, Object>();

        try {
            /* 校验 */
            Assert.notNull(accountId, "-10001", "品牌id不能为空");
            Assert.notNull(busType, "-10002", "业务类型不能为空");

            BusDesConfig busDesConfig = busDesConfigService.getByAccountId(accountId, busType);

            map.put(ResponseCode.RET, ResponseCode.SUCC);
            map.put(ResponseCode.DATA, busDesConfig);
        } catch (BaseException e) {
            ResponseCode.printException(map, e, request);
        }
        OutputUtil.renderText(request, response, map);
    }

}
